﻿<Window x:Class="CloudClipboardSync.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:Clipboard="clr-namespace:DAL.Clipboard;assembly=DAL"
        Title="Clipboard History :: Cloud Clipboard Sync" Height="350" Width="525"
        DataContext="{StaticResource programData}">
    <Grid>
        <ListBox ItemsSource="{Binding ClipboardHistory}" HorizontalContentAlignment="Stretch" SelectedItem="{Binding SelectedClipboard}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Padding" Value="0" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate DataType="Clipboard:ClipboardContent">
                    <Border BorderBrush="Silver" BorderThickness="5 0 0 0" Margin="2" Background="Transparent" PreviewMouseDown="ListItemPreviewMouseDown">
                        <Grid Margin="5 0">
                            <TextBlock Text="{Binding Time, Mode=OneWay}" DockPanel.Dock="Top" FontWeight="Bold" HorizontalAlignment="Right" VerticalAlignment="Top"/>
                            <StackPanel>                                
                                <StackPanel Visibility="{Binding Rtf, Converter={StaticResource VisibleIfNotNull}, Mode=OneWay}" Margin="0 0 0 5">
                                    <TextBlock Text="Rtf" FontWeight="Bold" Margin="0 0 0 5"/>
                                    <xctk:RichTextBox Text="{Binding Rtf, Mode=OneWay}" BorderThickness="0" Margin="4 0 0 0" MaxHeight="100"
                                            ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                            IsDocumentEnabled="false" IsReadOnly="true" Focusable="False" Background="Transparent"/>
                                </StackPanel>
                                <StackPanel Visibility="{Binding Text, Converter={StaticResource VisibleIfNotNull}, Mode=OneWay}" Margin="0 0 0 5">                                    
                                    <TextBlock Text="Text" FontWeight="Bold"/>
                                    <TextBox MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Text="{Binding Text, Mode=OneWay}" Margin="4 0 0 0" TextWrapping="Wrap" 
                                             IsReadOnly="True" BorderThickness="0" Background="Transparent"/>
                                </StackPanel>
                                <StackPanel Grid.Column="1" Visibility="{Binding Image, Converter={StaticResource VisibleIfNotNull}, Mode=OneWay}" Margin="0 0 0 5">
                                    <TextBlock Text="Image" FontWeight="Bold" Margin="0 0 0 5"/>
                                    <Image Source="{Binding Image, Mode=OneWay}" MaxHeight="100"/>
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="No clipboard history :(" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="18" 
                   Visibility="{Binding ClipboardHistory.Count, Converter={StaticResource VisibleIfParam}, ConverterParameter='0'}"/>
    </Grid>
</Window>
